package com.sofwin.config;/**
 * @PackageName:com.sofwin.config
 * @author:andyLiu
 * @DateTime:2020/12/30 9:43
 * @Description:[TODO]输入当前模块作用
 **/

import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;

import javax.servlet.Filter;

/**
 * @ClassName: WebApplicationInitalize
 * @Description: TODO
 * @Author: andyliu
 * @Date: 2020/12/30 9:43
 * @Version: 1.0
 **/
public class WebApplicationInitalize extends AbstractAnnotationConfigDispatcherServletInitializer {
    /**
     * 设置根配置信息
     * @return
     */
    @Override
    protected Class<?>[] getRootConfigClasses() {
        return new Class[]{Configuration.class};
    }

    /**
     * 设置servlet配置信息
     * @return
     */
    @Override
    protected Class<?>[] getServletConfigClasses() {
        return new Class[]{Configuration.class};
    }

    /**
     * 设置dispatcherServlet的url-pattern
     * @return
     */
    @Override
    protected String[] getServletMappings() {
        return new String[]{"/"};
    }

    /**
     * 设置过滤器
     * @return
     */
    @Override
    protected Filter[] getServletFilters() {
        Filter characterEncoding = new CharacterEncodingFilter("UTF-8");
        return new Filter[]{characterEncoding};
    }
}
